package com.kcyu.sfherp.controller;

import com.kcyu.sfherp.service.FileServer;
import com.kcyu.sfherp.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/download")
public class DownloadController {

    @Autowired
    private FileServer fileServer;

    @GetMapping("/temp")
    public void downloadFromTempDir(@RequestParam String fileName, HttpServletResponse response) throws Exception {
        try {
            fileServer.downloadFromTempDir(fileName, response);
        } catch (Exception e) {
            e.printStackTrace();
            throw new Exception("下载失败");
        }
    }

}
